<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Format</title>
</head>

<body>
    <a href="./New Text Document.doc" download="testdownload.doc">download</a>
    <script>
        let arr = [
            { number: '1000100', level: 0, label: 'topmenu1', children: [{ number: '1000110', level: 1, label: 'firstmenu11', children: [] }, { number: '1000120', level: 1, label: 'firstmenu12', children: [] }] },
            { number: '1000200', level: 0, label: 'topmenu2', children: [{ number: '1000210', level: 1, label: 'firstmenu21', children: [] }, { number: '1000220', level: 1, label: 'firstmenu22', children: [] }] },
            { number: '1000300', level: 0, label: 'topmenu3', children: [{ number: '1000310', level: 1, label: 'firstmenu31', children: [] }, { number: '1000320', level: 1, label: 'firstmenu32', children: [{ number: '1000321', level: 2, label: 'firstmenu32', children: [] }] }] }
        ]

        let formatedArr = []

        function getFormat(arr, formatedArr) {
            if (arr.length > 0) {
                for (let i = 0; i < arr.length; i++) {
                    if (arr[i].children.length > 0) {
                        let arrTemplate = []
                        arrTemplate = getFormat(arr[i].children, arrTemplate)
                        formatedArr.push({ label: arr[i].label, value: arr[i].number, children: arrTemplate })

                    } else {
                        formatedArr.push({ label: arr[i].label, value: arr[i].number })
                    }
                }
            }
            return formatedArr
        }
        let newArr = getFormat(arr, formatedArr)
        console.log(newArr)
        let newLabel=''
        function findLabel(arr, value) {
          
            for (let i = 0; i < arr.length; i++) {
                if(arr[i].number ==value) {
                    newLabel = arr[i].label 
                    return newLabel
                }else{
                    if(arr[i].cildren&&arr[i].cildren.length>0){
                        findLabel(arr[i].cildren,value)
                    }

                }
            }
           
        }
        findLabel(newArr, '1000310')
      console.log()  
      console.log(newLabel)
    </script>

</body>

</html>